﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IN = Criteria.Interface;
using OC = Criteria.OneCriteria;
using TC = Criteria.TwoCriteria;

namespace Criteria
{
    class Program
    {
        static void Main(string[] args)
        {
            List<IN.Person> list = new List<IN.Person>();
            list.Add(new IN.Person("yuanloo", "female", "single"));
            list.Add(new IN.Person("yuan", "female", "maritied"));
            list.Add(new IN.Person("ming", "male", "single"));
            list.Add(new IN.Person("minglee", "male", "maritied"));
            list.Add(new IN.Person("lili", "female", "single"));

            IN.Criteria male = new OC.CriteriaMale();
            IN.Criteria female = new OC.CriteriaFemale();
            IN.Criteria single = new OC.CriteriaSingle();
            IN.Criteria singleFemail = new TC.AndCriteria(single,female);
            IN.Criteria singleOrFemale = new TC.OrCriteria(single,female);

            Console.WriteLine("male:");
            print(male.MeetCriteria(list));

            Console.WriteLine("female:");
            print(female.MeetCriteria(list));

            Console.WriteLine("single:");
            print(single.MeetCriteria(list));

            Console.WriteLine("singleFemail:");
            print(singleFemail.MeetCriteria(list));

            Console.WriteLine("singleOrFemale:");
            print(singleOrFemale.MeetCriteria(list));

            Console.ReadKey();
        }

        public static void print(List<IN.Person> list)
        {
            if (list == null || list.Count == 0)
            {
                return;
            }
            foreach (var item in list)
            {
                Console.WriteLine(string.Format("Person:[Name:{0},Gender:{1},Marital Status:{2}]", item.Name, item.Gender, item.MaritalStatus));
            }
        }
    }
}
